package Jw20241017;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description: 栈：7-1 符号配对
 * User: 王圆豪
 * Date: 2024-10-17
 * Time: 23:36
 */
public class Test{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = null;
        boolean pp = true;
        String tmp = null;
        Stack<String> stack = new Stack<>();
        while(!(s = sc.nextLine()).equals(".")){
            for(int i = 0; i < s.length(); i++){
                String c = String.valueOf(s.charAt(i));
                if(c.equals("/") && (i+1) < s.length() && String.valueOf(s.charAt(i + 1)).equals("*")){
                    c = "/*";
                    i++;
                }
                if (c.equals("*") && (i+1) < s.length() && String.valueOf(s.charAt(i + 1)).equals("/")){
                    c = "*/";
                    i++;
                }
                if(c.equals("(") || c.equals("{") || c.equals("[") || c.equals("/*")){
                    stack.push(c);
                }else if(c.equals(")") || c.equals("}") || c.equals("]") || c.equals("*/")){
                    if (stack.isEmpty()) {
                        tmp = c;
                        pp = false;
                        break;
                    }
                    tmp = stack.peek();
                    if(c.equals("}")){
                        if(!tmp.equals("{")){
                            pp = false;
                        }else{
                            stack.pop();
                        }
                    }
                    if(c.equals("]")){
                        if(!tmp.equals("[")){
                            pp = false;
                        }else{
                            stack.pop();
                        }
                    }
                    if(c.equals(")")){
                        if(!tmp.equals("(")){
                            pp = false;
                        }else{
                            stack.pop();
                        }
                    }if(c.equals("*/")){
                        if(!tmp.equals("/*")){
                            pp = false;
                        }else{
                            stack.pop();
                        }
                    }
                }
                if(!pp){
                    break;
                }
            }
            if(!pp){
                break;
            }
        }
        if(!pp){
            System.out.println("NO");
            if(tmp.equals("(")) System.out.print("(-?");
            if(tmp.equals("[")) System.out.print("[-?");
            if(tmp.equals("{")) System.out.print("{-?");
            if(tmp.equals("/*")) System.out.print("/*-?");
            if(tmp.equals(")")) System.out.print("?-)");
            if(tmp.equals("]")) System.out.print("?-]");
            if(tmp.equals("}")) System.out.print("?-}");
            if(tmp.equals("*/")) System.out.print("?-*/");
        }else{
            if(stack.isEmpty()){
                System.out.print("YES");
            }else{
                System.out.println("NO");
                String l = stack.peek();
                if(l.equals("(")) System.out.print("(-?");
                if(l.equals("[")) System.out.print("[-?");
                if(l.equals("{")) System.out.print("{-?");
                if(l.equals("/*")) System.out.print("/*-?");
            }
        }
    }
}